﻿using System.Collections.Generic;

namespace CoreEx.Common.Validation
{
    /// <summary>
    /// Represents a class that is capable of validating a list of validation rules.
    /// </summary>
    public interface IRulesValidator
    {
        /// <summary>
        /// Validates a list of <see cref="IValidationRule{T}"/> instances and returns
        /// the returns the error message from the first rule that is considered invalid.
        /// </summary>
        /// <typeparam name="T">The target type that the validation rules applies to.</typeparam>
        /// <param name="validationRules">The list of <see cref="IValidationRule{T}"/> instances to validate.</param>
        /// <param name="target">The target instance to validate.</param>
        /// <returns>A <see cref="string"/> that contains a textual representation of the broken rule, if any.</returns>
        string Validate<T>(IEnumerable<IValidationRule<T>> validationRules, T target);
    }   
}
